from Finance_api import app


class RegisterAPI:
    def __init__(self):
        self.url_verify_code = app.BASE_URL + "common/public/verifycode1/" + app.nums
        self.url_phone_code = app.BASE_URL + "member/public/sendSms"
        self.url_register = app.BASE_URL + "member/public/reg"

    # 获取图片验证码
    def get_verify_code(self, session):
        return session.get(self.url_verify_code)

    # 获取手机验证码
    def get_phone_code(self, session, phone, verifycode, type):
        get_data = {
            "phone": phone,
            "imgVerifyCode": verifycode,
            "type": type
        }
        return session.post(url=self.url_phone_code,
                            data=get_data,
                            headers=app.headers_data)

    # 注册
    def register(self, session, register_data):
        return session.post(url=self.url_register,
                            data=register_data,
                            headers=app.headers_data)
